<include file="Public:headern" />
<div class="S-login_reg">
    <a href="{:U('Membership/login')}">登录账号</a><a href="{:U('Membership/register')}" class="cover">注册账号</a>
  </div>
  <div class="S-reg login_reg" >
   <form action="{:U('Membership/dregister')}" method="post"  id="form" role="form">
    <div class="S-form_box">
       <div class="height25"></div>
       <ul>
         <li class="phone"><input type="text" id="tel" name="tel" placeholder="请输入您的手机号码" class="text" /><a id="yzbutton" class="xym">获取验证码</a></li>
         <li class="xym"><input type="text" name="yanzheng" id="yanzheng" maxlength="6" placeholder="请输入您的手机验证码" class="text" required/>
         <input type="hidden" name="yanzhengagain" id="yanzhengagain" value="" />
         </li>
         <li class="password"><input type="password" id="pwd" name="pwd"  placeholder="请输入您的新密码" class="text" required/></li>
         <li class="password"><input type="password" id="pwdagain" name="pwdagain" placeholder="请确认您的新密码" class="text" required/></li>
         <input type="hidden" name="uid" value="{$uid}" />
       </ul>
       <input type="button" id="tijiao"  class="sub" value="注册" />
    </div>
   </form>
  </div>
  <script type="text/javascript">
   $('#yzbutton').bind("click",function(){
   	var tel = $('#tel').val();
   	var isMobile=/^(?:13\d|15\d|18\d)\d{5}(\d{3}|\*{3})$/;
   	
   	if(isMobile.test(tel)){
       	 $.ajax({
       			type:"post",
       			url:"{:U('Membership/rsendyz')}",
       			datatype:'json',
       			data:{tel:tel},
       			success:function(result){
       				datacontent =window.JSON.parse(result);
       				if(datacontent.flag==1){
       					alert(datacontent.msg);
       				}else {
       					$('#yanzhengagain').val(datacontent.yanzhengma);
       					alert(datacontent.msg+datacontent.yanzhengma);
       				}
       				
       			},
       			error: function(XMLHttpRequest, textStatus, errorThrown) {
       				alert(XMLHttpRequest.status);
       				alert(XMLHttpRequest.readyState);
       				alert(textStatus);
       			},
       		});
        } else {
       	 alert("请正确填写电话号码，例如:13415764179"); 
        }
   	
   });

   $('#tijiao').bind("click",function(){
   	var yanzheng = $('#yanzheng').val();
   	var yanzhengagain = $('#yanzhengagain').val();
   	var pwd = $('#pwd').val();
   	var pwdagain = $('#pwdagain').val();
   	
   	if(yanzheng==''){
   		alert('验证码不能为空！');
   		return false;
   	}else{
   		if(yanzheng!=yanzhengagain){
   			alert('验证码输入错误！');
   			return false;
   		}else if(pwd==''||pwd!=pwdagain){
   			alert('两次输入的密码不相同！');
   			return false;
   		}else{
   			$('#form').submit();
   		}
   	}
   	
   	
   });
  
   $(function(){
        if('{$msg}'!='0'){
            alert('{$msg}');
        }
    });
 
</script>
<include file="Public:footern" />
